package com.lijing.mock.web;

import com.lijing.mock.enums.MockDataTypeEnum;
import com.lijing.mock.manager.UrlMockManager;
import com.lijing.mock.model.bo.UrlMockBO;
import com.lijing.mock.model.dto.UrlBaseDTO;
import com.lijing.mock.model.dto.UrlMockDTO;
import com.lijing.mock.services.MockServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * mock主入口
 * @author by lijing
 * @date 2019/12/2 0002 11:38
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/mock-api")
public class MockApi {

    @Autowired
    private MockServer mockServer;

    @Autowired
    private UrlMockManager urlMockManager;

    @ResponseBody
    @RequestMapping(value = "/post", method = RequestMethod.POST)
    public String mockPost(){
        log.info("request post");

        return mockServer.getMockResult();
    }

    @ResponseBody
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public String mockGet(){
        log.info("request get");

        return mockServer.getMockResult();
    }

    @ResponseBody
    @RequestMapping(value = "/urlTest", method = RequestMethod.GET)
    public String urlTest(){
        log.info("request get url");

        return "Url Test";
    }

    @ResponseBody
    @RequestMapping(value = "/error")
    public String error(){
        log.info("this is error");

        return "this url is error";
    }

}
